'Check whether VBA in xls or not
'need VBA extensibility)

Function CheckMacro(FileName As String) As Boolean
    Dim vbc As VBComponent, i As Long
    Dim wbk As Workbook
    Application.EnableEvents = False
    Set wbk = Workbooks.Open(FileName)
    CheckMacro = False
    For Each vbc In wbk.VBProject.VBComponents
        With vbc.CodeModule
            For i = 1 To .CountOfLines
                If .ProcOfLine(i, vbext_pk_Get) <> "" Or _
                   .ProcOfLine(i, vbext_pk_Let) <> "" Or _
                   .ProcOfLine(i, vbext_pk_Set) <> "" Or _
                   .ProcOfLine(i, vbext_pk_Proc) <> "" Then
                    CheckMacro = True
                    Exit For
                End If
            Next
        End With
        If CheckMacro Then Exit For
    Next
    Application.EnableEvents = True
    wbk.Close
End Function
